/**
 * 路由配置规则
 */
/**
 * 配置路由：
 * 1. 动态导入要配置组件
 * 2. 配置
 */
// 标签页=》公共布局组件（一级路由）
const Layout = () => import('@/views/layout')
// 首页=》第一个标签页页面(二级路由)
const Home = () => import('@/views/home')
// 问答=》第二个标签页页面(二级路由)
const Question = () => import('@/views/question')
// 视频=》第三个标签页页面(二级路由)
const Video = () => import('@/views/video')
// 我的=》第四个标签页页面(二级路由)
const Profile = () => import('@/views/profile')
// 编辑用户资料
const User = () => import('@/views/user')
// 小智同学智联聊天
const Chat = () => import('@/views/user/chat')
// 登录
const Login = () => import('@/views/login')
// 搜索
const Search = () => import('@/views/search')
// 搜索结果页面
const Result = () => import('@/views/search/result')
// 文章详情
const Article = () => import('@/views/article')

const routes = [
  // 标签栏相关路由
  {
    path: '/',
    // 公共布局
    component: Layout,
    children: [
      // 标签页页面（4个）
      {
        path: '/',
        name: 'home',
        component: Home,
        // 需要缓存
        meta: { isKeepAlive: true }
      },
      {
        path: '/question',
        name: 'question',
        component: Question
      },
      {
        path: '/video',
        name: 'video',
        component: Video
      },
      {
        path: '/user',
        name: 'profile',
        component: Profile
      }
    ]
  },
  // 编辑用户个人资料
  {
    path: '/user/profile',
    name: 'user',
    component: User
  },
  // 小智聊天
  {
    path: '/user/chat',
    name: 'chat',
    component: Chat
  },
  // 登录
  {
    path: '/login',
    name: 'login',
    component: Login
  },
  // 搜索
  {
    path: '/search',
    name: 'search',
    component: Search
  },
  // 搜索结果页
  {
    path: '/search/result',
    name: 'result',
    component: Result
  },
  // 文章详情
  {
    path: '/article/:id',
    name: 'article',
    component: Article,
    // 需要缓存
    meta: { isKeepAlive: true }
  }

]

export default routes
